<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Enumerate all assigned Unicode characters within a range</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlchar.digit.html">« IntlChar::digit</a></li>
      <li style="float: right;"><a href="intlchar.enumchartypes.html">IntlChar::enumCharTypes »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlchar.html">IntlChar</a></li>
    <li>Enumerate all assigned Unicode characters within a range</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlchar.enumcharnames" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlChar::enumCharNames</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">IntlChar::enumCharNames</span> &mdash; <span class="dc-title">Enumerate all assigned Unicode characters within a range</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlchar.enumcharnames-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>IntlChar::enumCharNames</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$start</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$end</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = IntlChar::UNICODE_CHAR_NAME</span></span><br>): <span class="type"><span class="type">?</span><span class="type">bool</span></span></div>

  <p class="para rdfs-comment">
   Enumerate all assigned Unicode characters between the start and limit code points (start inclusive, limit exclusive)
   and call a function for each, passing the code point value and the character name.
  </p>
  <p class="para">
   For Unicode 1.0 names, only those are enumerated that differ from the modern names.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlchar.enumcharnames-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">start</code></dt>

    <dd>

     <p class="para">
      The first code point in the enumeration range.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">end</code></dt>

    <dd>

     <p class="para">
      One more than the last code point in the enumeration range (the first one after the range).
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">callback</code></dt>

    <dd>

     <p class="para">
      The function that is to be called for each character name.  The following three arguments will be passed into it:
      <ul class="simplelist">
       <li class="member"><span class="type">int</span> <code class="literal">$codepoint</code> - The numeric code point value</li>
       <li class="member"><span class="type">int</span> <code class="literal">$nameChoice</code> - The same value as the <code class="parameter">type</code> parameter below</li>
       <li class="member"><span class="type">string</span> <code class="literal">$name</code> - The name of the character</li>
      </ul>
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">type</code></dt>

    <dd>

     <p class="para">
      Selector for which kind of names to enumerate.  Can be any of these constants:
      <ul class="simplelist">
       <li class="member"><strong><code>IntlChar::UNICODE_CHAR_NAME</code></strong> (default)</li>
       <li class="member"><strong><code>IntlChar::UNICODE_10_CHAR_NAME</code></strong></li>
       <li class="member"><strong><code>IntlChar::EXTENDED_CHAR_NAME</code></strong></li>
       <li class="member"><strong><code>IntlChar::CHAR_NAME_ALIAS</code></strong></li>
       <li class="member"><strong><code>IntlChar::CHAR_NAME_CHOICE_COUNT</code></strong></li>
      </ul>
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlchar.enumcharnames-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>null</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-intlchar.enumcharnames-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2498">
   <p><strong>示例 #1 Enumerating over a sample range of code points</strong></p>
   <div class="example-contents">
    <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">enumCharNames</span><span style="color: #007700">(</span><span style="color: #0000BB">0x2600</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x2610</span><span style="color: #007700">,&nbsp;function(</span><span style="color: #0000BB">$codepoint</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$nameChoice</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"U+%04x&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$codepoint</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">);<br />});<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
    <div class="cdata"><pre>
U+2600 BLACK SUN WITH RAYS
U+2601 CLOUD
U+2602 UMBRELLA
U+2603 SNOWMAN
U+2604 COMET
U+2605 BLACK STAR
U+2606 WHITE STAR
U+2607 LIGHTNING
U+2608 THUNDERSTORM
U+2609 SUN
U+260a ASCENDING NODE
U+260b DESCENDING NODE
U+260c CONJUNCTION
U+260d OPPOSITION
U+260e BLACK TELEPHONE
U+260f WHITE TELEPHONE
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-intlchar.enumcharnames-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="intlchar.charname.html" class="function" rel="rdfs-seeAlso">IntlChar::charName()</a> - Retrieve the name of a Unicode character</span></li>
    <li class="member"><span class="function"><a href="intlchar.charfromname.html" class="function" rel="rdfs-seeAlso">IntlChar::charFromName()</a> - Find Unicode character by name and return its code point value</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>